const { createProxyMiddleware } = require('http-proxy-middleware')

module.exports = function (app) {
  app.use(
    '/api',
    createProxyMiddleware({
      target: 'http://localhost:5000',
      changeOrigin: true,
      pathRewrite: {
        '^/api': '/',
      },
    }),
  )

  app.use(
    '/chouti-imgs',
    createProxyMiddleware({
      target: 'https://img3.chouti.com',
      changeOrigin: true,
      pathRewrite: {
        '^/chouti-imgs': '/',
      },
      headers: {
        Referer: 'https://dig.chouti.com',
      },
    }),
  )
  //https://pic3.tudouxy01.com/tu/contents/20211125/0c781518f9874429b86500cbd4c45dad14fe9685.jpg?x-oss-process=style/600
  // app.use(
  //   '/chouti-imgs',
  //   createProxyMiddleware({
  //     target: 'https://pic3.tudouxy01.com',
  //     changeOrigin: true,
  //     pathRewrite: {
  //       '^/chouti-imgs': '/',
  //     },
  //   }),
  // )
}
